package leetcode.Hot100;

import leetcode.TreeNode;

/**
 * @author Cheng Jun
 * Description: 翻转一棵二叉树。
 * https://leetcode-cn.com/problems/invert-binary-tree/
 * @version 1.0
 * @date 2021/12/3 17:17
 */
public class invertTree {

    // 传入一个节点，左右子节点互换
    static TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode temp = root.left;
        root.left = invertTree(root.right);
        root.right = invertTree(temp);
        return root;
    }
}
